package com.ct.entity.enums;

import com.ct.utils.StringTools;

public enum TravelApprovalEnum {
    UNPROCESSED(0, "未处理"),
    APPROVED(1, "批准"),
    REJECTED(2, "拒绝");

    private Integer type;
    private String desc;

    TravelApprovalEnum() {
    }

    TravelApprovalEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static TravelApprovalEnum getByName(String name) {
        try {
            if (StringTools.isEmpty(name)) {
                return null;
            }
            return TravelApprovalEnum.valueOf(name.toUpperCase());
        } catch (IllegalArgumentException e) {
            return null;
        }
    }

    public static TravelApprovalEnum getByType(Integer type) {
        for (TravelApprovalEnum travelApprovalEnum : TravelApprovalEnum.values()) {
            if ((travelApprovalEnum.getType() == type)) {
                return travelApprovalEnum;
            }
        }
        return null;
    }
}
